<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Product_mdl extends CI_Model{
    function __construct(){
        parent::__construct();
        $this->load->database();
    
    }
    
	public function getListProduct(){
		$this->db->select('ProductName,QuantityPerUnit');
		$this->db->from('products');
		$query=$this->db->get();
		$rows=$query->result();
		if($query->num_rows > 0){
			foreach($rows as $row)
				$data[] = Array(
						'productName'=>$row->ProductName,
						'quantityPerUnit'=>$row->QuantityPerUnit
			);
			
			return $data;
		}
		return null;
	}
	
	public function SaveAdd($data){
		$this->db->insert('Products',$data);
	}
	
	public function SaveEdit($data){
		$this->db->where('productname',$productName);
		$this->db->update('Products',$data);
	}
	
	public function Delete($data){
		
		//$this->db->delete('Products',array('productname' => $productName));
		$this->db->delete('Products',$data);
	}
	
}	
?>